<template>
<el-dialog v-model="subjectDialog" title="关联学科" width="500">
<el-form>
  <div class="mt-4">
    <el-checkbox-group v-model="props.formData.subjectNameList">
      <el-checkbox
          v-for="(item,index) in props.subjectNameList"
          :value="item.id"
          :label="item.subjectName"
          border
          style="margin: 5px 5px"

      >
      </el-checkbox>
    </el-checkbox-group>
  </div>
</el-form>
  <template #footer>
    <div class="dialog-footer">
      <el-button @click="subjectDialog = false">取消</el-button>
      <el-button type="primary" @click="update" :disabled="isDisable">
        保存
      </el-button>
    </div>
  </template>
</el-dialog>
</template>

<script setup>
import axios from "@/axios/index";
import { ElMessage } from "element-plus";
import { ref } from "vue";
import LoginView from "@/views/LoginView.vue";
let props = defineProps(["subjectNameList", "empId", "formData"]);

let subjectDialog = defineModel("subjectDialog");

let subjectId = ref([]);

//避免重复点击
let isDisable = ref(false);


//关联提交修改功能
function update() {
  isDisable.value = true;
  //修改学科

  axios.get("/staffSubject/updateStaffSubject", {
    params: {
      empId: props.empId,
      subjectIdList:props.formData.subjectNameList.join(','),
    }
  })
      .then((resp) => {
        subjectDialog.value = false;
        isDisable.value = false;
        ElMessage({
          message: resp.data.message,
          type: "success",
          duration: 500,
        });
      });
}
</script>

<style scoped>

</style>